`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    15:14:45 07/23/2015 
// Design Name: 
// Module Name:    ForwardingUnit 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module ForwardingUnit(
	input [4:0] Rs,
	input [4:0] Rt,
	input [4:0] RdE4,
	input [4:0] RdE5,
	input regWriteE4,
	input regWriteE5,
	output reg [1:0] forwardA,
	output reg [1:0] forwardB
    );

//Dukes of Hazard
always@* begin
	if(regWriteE4 && (RdE4 != 0) && (RdE4 == Rs)) forwardA = 2'b 10;
	else if(regWriteE5 && (RdE5 != 0) && (RdE5 == Rs) && (RdE4 != Rs)) forwardA = 2'b 11;
	else forwardA = 2'b 00;

	if(regWriteE4 && (RdE4 != 0) && (RdE4 == Rt)) forwardB = 2'b 10;
	else if(regWriteE5 && (RdE5 != 0) && (RdE5 == Rt) && (RdE4 != Rt)) forwardB = 2'b 11;
	else forwardB = 2'b 00;
end
endmodule
